#pragma once
#include <iostream>             
#include <pcl/io/pcd_io.h>    // pcd相关头文件
#include <pcl/point_types.h>  // 所有点类型定义头文件
#include <pcl/io/ply_io.h>    // ply类相关头文件
#include <pcl/point_types.h>
#include <pcl/visualization/pcl_visualizer.h>
#include <pcl/point_cloud.h>
#include <pcl/visualization/cloud_viewer.h>
#include <fmt/format.h>
#include <fmt/color.h>
#include <fmt/ostream.h>
#include <fmt/os.h>
#include <thread>
#include <chrono>
void PLY2PCD(const std::string &ply_file_path,std::string pcd_file_path){
	pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
	if (pcl::io::loadPLYFile<pcl::PointXYZ>(ply_file_path, *cloud) == -1)
	{
		fmt::print(fg(fmt::color::red) | fmt::emphasis::bold,"load {0} error\n",ply_file_path);
	}
	pcl::PCDWriter writer;
	writer.write(pcd_file_path, *cloud);  //保存文件
	fmt::print(fg(fmt::color::green) | fmt::emphasis::bold,"save {0} ok\n",pcd_file_path);
}

//TODO ： 重新写个类封装线程
void showPointCouldForver(pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud){
	pcl::visualization::CloudViewer viewer("Simple Cloud Viewer");
	viewer.showCloud(cloud);
	while (!viewer.wasStopped())
	{
		std::this_thread::sleep_for(std::chrono::seconds(1));
	}
}